/**
 *
 */
package net.eldeen.stockhack.service;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.log4j.Logger;

import net.eldeen.stockhack.model.Stock;

/**
 * @author heldeen
 *
 */
public class SimpleStockListener implements DataObserver<List<Stock>> {

  private static final Logger LOGGER = Logger.getLogger(SimpleStockListener.class);

  private AtomicInteger updateCount;

  public SimpleStockListener() {
    updateCount = new AtomicInteger(0);
  }

  /* (non-Javadoc)
   * @see net.eldeen.stockhack.service.DataObserver#update()
   */
  public void update(List<Stock> data) {

    int updateNum = updateCount.incrementAndGet();
    for (Stock stock : data) {
      LOGGER.info("Update: " + updateNum + " " + stock);
    }

  }

}
